package design_pattern.chain_of_responsibility;

/**
 * Created by WeiDingKuo on 2017/10/26 18:28
 * <p>
 * 责任链模式
 * <p>
 * 责任链上每个节点内包含下一个节点的引用
 * 待处理的request内包含可供节点判断的条件
 * 满足条件则当前节点进行处理request
 * 不满足条件则交由下一个节点处理request
 * <p>
 * 责任链的节点的个数和顺序可以自由的组合
 */
public class test {
    public static void main(String[] args) {
        Request request = new Request();
        request.setType("a");

        Handler handlerChain = new HandlerImpl1(new HandlerImpl2(new HandlerImpl3()));
        handlerChain.handleRequest(request);

        request.setType("b");
        handlerChain.handleRequest(request);

        request.setType("c");
        handlerChain.handleRequest(request);
    }
}
